﻿namespace Core.RabbitMQ.Attribute
{
    /// <summary>
    /// RabbitMQ消费消息配置
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class RabbitMqMessageAttribute : System.Attribute
    {
        public RabbitMqMessageAttribute(string queueName, string exchange="", ExchangeTypeEnum exchangeType= ExchangeTypeEnum.Topic, string routingKey="", ushort prefetchCount=1, int queueTtl= 3600000)
        {
            QueueName = queueName;
            Exchange = exchange;
            ExchangeType= exchangeType;
            RoutingKey = routingKey;
            PrefetchCount = prefetchCount;
            QueueTtl = queueTtl;

        }


        /// <summary>
        /// 队列名称
        /// </summary>
        public string QueueName { get; set; }
        /// <summary>
        /// 交换机名称
        /// </summary>
        public string? Exchange { get; set; }

        /// <summary>
        /// 交换机类型
        /// </summary>
        public ExchangeTypeEnum ExchangeType { get; set; }

        /// <summary>
        /// 路由键
        /// </summary>
        public string? RoutingKey { get; set; }


        /// <summary>
        /// 消费者预取计数
        /// </summary>
        public ushort PrefetchCount { get; set; }

        /// <summary>
        /// 队列过期时间
        /// </summary>
        public int QueueTtl { get; set; }
    }
}
